<?php

namespace App\Http\model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class Dictionary extends Model
{

	/**
	 * @Author   张吉星
	 * @DateTime 2018-05-24
	 * @version  0.8
	 */
	public function dictionary($value){
		if($value){
			$value = explode(',', $value); //把type字段分割数组,下标0为字典ID 下标1为字典contents下标
	        // 获取对应的字典信息
	        $zidian = Db::table('dictionary')
	            ->where('id',$value[0])
	            ->first();
	        $zidian = json_decode(json_encode($zidian),true);
	        // print_r($contents);exit;
	        $data = json_decode($zidian['contents'],true)[$value[1]]['value'];
	        return $data;
		}else{
			return [];
		}
	}
}
